<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Hais丶定制</title>
    <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
          rel="stylesheet">
    <link href="css/sb-admin-2.min.css" rel="stylesheet">
</head>

<body id="page-top">

<div id="wrapper">
    <!-- Sidebar -->
    <ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">
        <!-- Sidebar - Brand -->
        <a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.html">
            <div class="sidebar-brand-icon rotate-n-15">
                <i class="fas fa-laugh-wink"></i>
            </div>
            <div class="sidebar-brand-text mx-3">Hais丶定制 <sup>v4</sup></div>
        </a>

        <!-- Divider -->
        <hr class="sidebar-divider">
        <div class="sidebar-heading">Hais丶定制</div>
        <!-- Nav Item - Charts -->
        <li class="nav-item">
            <a class="nav-link" href="#" onclick="loadUrlToIframe('make-post.html?r=9')">
                <i class="fas fa-fw fa-chart-area"></i>
                <span>我要定制</span>
            </a>
            <a class="nav-link" href="#" onclick="loadUrlToIframe('index-main.html')">
                <i class="fas fa-fw fa-chart-area"></i>
                <span>任务列表</span>
            </a>
        </li>

        <!-- Divider -->
        <hr class="sidebar-divider">

        <!-- Heading -->
        <div class="sidebar-heading">小米官方文件</div>
        <li class="nav-item">
            <a class="nav-link"  target="_blank" href="https://zivlw.lanzoui.com/s/28256">
                <i class="fas fa-fw fa-chart-area"></i>
                <span>官方APK</span>
            </a>
        </li>
        <li class="nav-item">
            <a class="nav-link"  target="_blank" href="https://xiaomirom.com/series/">
                <i class="fas fa-fw fa-chart-area"></i>
                <span>官方ROM</span>
            </a>
        </li>
        <!-- Divider -->
        <hr class="sidebar-divider">

        <!-- Heading -->
        <div class="sidebar-heading">友情链接</div>
        <li class="nav-item">
            <a class="nav-link"  target="_blank" href="http://mi.fiime.cn">
                <i class="fas fa-fw fa-chart-area"></i>
                <span>FiimeROM</span>
            </a>
        </li>


        <!-- Divider -->
        <hr class="sidebar-divider d-none d-md-block">

        <!-- Sidebar Toggler (Sidebar) -->
        <div class="text-center d-none d-md-inline">
            <button class="rounded-circle border-0" id="sidebarToggle"></button>
        </div>

    </ul>
    <!-- End of Sidebar -->

    <!-- Content Wrapper -->
    <div id="content-wrapper" class="d-flex flex-column">

        <!-- Main Content -->
        <div id="content">

            <!-- Topbar -->
            <nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">

                <!-- Sidebar Toggle (Topbar) -->
                <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
                    <i class="fa fa-bars"></i>
                </button>

                <!-- Topbar Search -->
                <form class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100 navbar-search">
                    <div class="input-group">
                        <input type="text" class="form-control bg-light border-0 small" placeholder="合适才是最好的，Hais给你随心定制！" aria-label="Search" aria-describedby="basic-addon2">
                    </div>
                </form>

                <!-- Topbar Navbar -->
                <ul class="navbar-nav ml-auto">
                    <!-- Nav Item - User Information -->
                    <li class="nav-item dropdown no-arrow">
                        <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            <span class="mr-2 d-none d-lg-inline text-gray-600 small" id="nikename">未登录</span>
                            <img class="img-profile rounded-circle" src="img/undraw_profile.svg" id="photo">
                        </a>
                        <!-- Dropdown - User Information -->
                        <div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="userDropdown">
                            <div class="form-group" style="text-align: center;margin: 6px 12px" id="loginLayout">
                                <input type="number" class="form-control form-control-user" id="username" placeholder="QQ账号" style="margin-bottom: 12px">
                                <input type="password" class="form-control form-control-user" id="password" placeholder="登录密码" style="margin-bottom: 12px">
                                <a href="user-register.html" class="btn btn-success btn-icon-split btn-sm">
                                    <span class="text">注册</span>
                                </a>
                                <a href="#" id="login" class="btn btn-success btn-icon-split btn-sm">
                                    <span class="text">登录</span>
                                </a>
                                <br/>
                                <div class="dropdown-divider"></div>
                                <a class="dropdown-item" style="margin-top: 6px" href="user-forgot-password.html">
                                    忘记密码
                                </a>
                            </div>
                            <div class="form-group" style="text-align: center;margin: 6px 12px" id="userLayout">
                                <a class="dropdown-item" style="margin-top: 6px" href="#" onclick="loadUrlToIframe('user-info.html')">
                                    我的定制
                                </a>
                                <a class="dropdown-item" style="margin-top: 6px" href="user-recharge.html">
                                    我要充值
                                </a>
                                <a class="dropdown-item" style="margin-top: 6px" href="user-update.html">
                                    我要升级
                                </a>
                                <a class="dropdown-item" style="margin-top: 6px" href="#" onclick="cleanUserInfo()">
                                    退出登录
                                </a>
                            </div>
                        </div>
                    </li>

                </ul>

            </nav>
            <!-- End of Topbar -->

            <!-- Begin Page Content -->

            <div class="container-fluid">
                <iframe src="index-main.html" onload="resizeIframe(this)" width="100%" height="100%" name="mainIframe" id="mainIframe" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"></iframe>
            </div>
        </div>
    </div>
    <!-- End of Content Wrapper -->

</div>

<!-- Bootstrap core JavaScript-->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

<!-- Core plugin JavaScript-->
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>

<!-- Custom scripts for all pages-->
<script src="js/sb-admin-2.min.js"></script>
<script>
    loadUserInfo();
    $("#login").click(function(){
        $.ajax({
            type: "get",
            data: "random="+Math.random(),
            url: "http://api.hais.pw/user/login?username="+$("#username").val()+"&password="+$("#password").val(),
            dataType: "json",
            success: function(data) {
                localStorage.setItem("user", JSON.stringify(data));
                localStorage.setItem("user_token", data.token);
                localStorage.setItem("user_id", data.id);
                console.log(data);
                loadUserInfo();
            },
            error: function(data) {
                alert(JSON.parse(data.responseText).message);
            }
        });
    });

    function loadUserInfo(){
        var user =JSON.parse(localStorage.getItem("user"));
        if(user!=null){
            $("#loginLayout").hide();
            $("#userLayout").show();
            $("#nikename").text(user.nikename);
            if(user.head !=null) {
                $("#photo").attr("src", user.head);
            }
        }else{
            $("#loginLayout").show();
            $("#userLayout").hide();
            $("#nikename").text("未登录");
        }
    }

    function loadUrlToIframe(url){
        $("#mainIframe").attr("src",url);
    }

    function cleanUserInfo(){
        localStorage.clear();
        loadUrlToIframe('index-main.html')
        loadUserInfo()
    }

    function resizeIframe(iframe) {
        window.setInterval(function(){
            iframe.height = iframe.contentWindow.document.body.scrollHeight + "px";
        },500);
    }

</script>


</body>

</html>
